package com.cmcc.linlaker.view;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;

import com.bumptech.glide.Glide;
import com.cmcc.linlaker.LoadingActivity;
import com.cmcc.linlaker.R;
import com.cmcc.linlaker.application.LinhuApp;
import com.nostra13.universalimageloader.core.ImageLoader;


public class BigImageDialog extends Dialog implements View.OnClickListener {
    private String url;
    private Context context;

    public BigImageDialog(Context context) {
        super(context);
    }


    public BigImageDialog(Context context, int theme, String url) {
        super(context, theme);
        this.context = context;
        this.url = url;
    }

    protected BigImageDialog(Context context, boolean cancelable,
                             OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }


    private ImageView image;
    private RelativeLayout layout_image;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_big_image);

        image = findViewById(R.id.image);
        image.getLayoutParams().width = LoadingActivity.screenWidth;

        ImageLoader.getInstance()
                .displayImage(url, image, LinhuApp.options);
//        Glide.with(context).load(url).placeholder(R.mipmap.image_default).into(image);

        layout_image = findViewById(R.id.layout_image);
        layout_image.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }


    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            default:
                break;
        }
    }
}
